﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Riel_Gestion.rielDataSetTableAdapters;

namespace Riel_Gestion
{
    public partial class FrmModificarProveedor : Form
    {
        private String idProveedor;
        public FrmModificarProveedor(String idProveedor)
        {
            this.idProveedor = idProveedor;
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (DialogResult.Yes == MessageBox.Show("¿Esta seguro que desea guardar los cambios?", "Editar Proveedor", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                PROVEEDORESTableAdapter adapter = new PROVEEDORESTableAdapter();
                adapter.UpdateProveedor(txtNombre.Text, txtResp.Text, txtTel.Text, txtDir.Text, txtEmail.Text, txtOtros.Text, int.Parse(idProveedor));
            }
            this.Close();
        }

        private void FrmModificarProveedor_Load(object sender, EventArgs e)
        {
            rielDataSet.PROVEEDORESDataTable dataTable = new rielDataSet.PROVEEDORESDataTable();
            PROVEEDORESTableAdapter adapter = new PROVEEDORESTableAdapter();
            adapter.FillByCodProv(dataTable, int.Parse(idProveedor));

            txtCodProv.Text = dataTable.Rows[0]["CODPROVEEDOR"].ToString();
            txtNombre.Text = dataTable.Rows[0]["NOMBRE"].ToString();
            txtResp.Text = dataTable.Rows[0]["RESPONSABLE"].ToString();
            txtTel.Text = dataTable.Rows[0]["TELEFONO"].ToString();
            txtDir.Text = dataTable.Rows[0]["DIRECCION"].ToString();
            txtEmail.Text = dataTable.Rows[0]["EMAIL"].ToString();
            txtOtros.Text = dataTable.Rows[0]["OTROS"].ToString();
        }
    }
}
